Demand-driven Search in Functional Logic Programs
نویسندگان
چکیده
In this paper we discuss the advantage of lazy functional logic languages to solve search problems. We show that the lazy evaluation strategy of such languages can be easily exploited to implement a solver that explores only the dynamically demanded parts of the search space. In contrast to pure logic programming, the use of nondeterministic functions enables a modular and simple implementation without the risk of floundering. Furthermore, a local encapsulation of search is useful to avoid the combinatorial explosion of the demanded search space. The necessary features (laziness, non-deterministic functions, encapsulated search) are available in Curry, a new declarative language intended to combine functional and logic programming techniques. We demonstrate the advantage of this approach with a musical application implemented in Curry: the generation of appropriate chords for the accompaniment of a given melody.
منابع مشابه
Dynamic Predicates in Functional Logic Programs
In this paper we propose a new concept to deal with dynamic predicates in functional logic programs. The definition of a dynamic predicate can change over time, i.e., one can add or remove facts that define this predicate. Our approach is easy to use and has a clear semantics that does not depend on the particular (demand-driven) evaluation strategy of the underlying implementation. In particul...
متن کاملDemand-Driven Dataflow for Concurrent Committed-Choice Code
Concurrent logic languages have been traditionally executed in a \greedy" fashion, such that computations are goal-driven. In contrast, non-strict functional programs have been traditionally executed in a \dataaow" fashion, such that computations are demand-driven. The latter method can be superior when allocation of resources such as memory is critical, which is usually the case for large, com...
متن کاملDemand-driven Search in Functional Logic Programs (Extended Abstract)
In this paper we discuss the advantage of lazy functional logic languages to solve search problems. We show that the lazy evaluation strategy of such languages can be easily exploited to implement a solver that explores only the dynamically demanded parts of the search space. In contrast to pure logic programming, the use of non-deterministic functions enables a modular and simple implementatio...
متن کاملImproving Lazy Non-Deterministic Computations by Demand Analysis
Functional logic languages combine lazy (demand-driven) evaluation strategies from functional programming with non-deterministic computations from logic programming. The lazy evaluation of non-deterministic subexpressions results in a demand-driven exploration of the search space: if the value of some subexpression is not required, the complete search space connected to it is not explored. On t...
متن کاملEfficient Compilation of Lazy Narrowing into Prolog
The paper presents new techniques for the transformation of lazy narrowing in logic programs. A formalism, called demand patterns, is introduced , and used to deene a demand driven strategy to compute lazy narrowing. The strategy is used to produce standard PROLOG code from programs written in a functional-logic language. Our method has a number of advantages over other approaches. While it can...
متن کامل